(function(app){
	app
		.controller("content_selectCtrl",["$scope","myFactory",'$http','$state','$stateParams','$q','$timeout','$ionicLoading',function($scope,myFactory,$http,$state,$stateParams,$q,$timeout,$ionicLoading){

            /*$scope.$on('$ionicView.beforeEnter', function() {
            	alert("enter before");
			})*/

			/*$scope.$on('$ionicView.afterEnter', function() {
		        alert("运行初始化函数");
		      })*/

			//接受参数
			var searchParam = $stateParams.searchParam;//接收从查询页面传送过来的查询条件
			var chdrnum01 = $stateParams.chdrnum01;
			var chdrcoy = $stateParams.chdrcoy;
			var token=sessionStorage.getItem("token");
			var flag1 = false;//因为该页面涉及两个初始化函数，有异步关系，不好做加载圈，设置两个标志用于检测是否都完成了
			var flag2 = false;
			var initFlag = false;//总体检测标志，在两个初始化函数完成后，会被置为true
			
			//前端查询界面采用缓存技术保存查询条件进行重新查询
			if(""!=searchParam && null!=searchParam && undefined!=searchParam){
				//localStorage.setItem("searchParam", searchParam);
				var searchParamSession = JSON.stringify(searchParam);
				//存入
				sessionStorage.obj = searchParamSession;

			}

			//绑定到页面上
			$scope.searchParam = searchParam;
			$scope.chdrnum01 = $stateParams.chdrnum01;
			$scope.chdrcoy = $stateParams.chdrcoy;

			//参数定义
			var policyData="";   //保单详情接收参数
			var initSelectItemData=""; //初始化变更项目数据
			var userPassItem=""; //用户初始化变更项目权限（即是哪些变更项目是有权限的，不过并非没权限就无法运行，而是显示灰色）

			$scope.load = function () {
				//alert("运行初始化函数");
				console.log("chdrnum01:"+chdrnum01+",chdrcoy:"+chdrcoy);
				//初始化函数：
				//$timeout(function(){myFactory.loadingHide();},2000);
				myFactory.loadingShow();//显示加载圈
				$scope.loadBdDetail();
				$scope.loadBgDetail();
			}
			

			$scope.loadBdDetail = function () {
				myFactory.loadingShow();//显示加载圈
				var timestamp=myFactory.getTimetamp();
				var sfis= "chdrnum-chdrcoy-token-timestamp";
				var signStr="chdrnum="+chdrnum01+"&chdrcoy="+chdrcoy+"&token="+token+"&timestamp="+timestamp;//encodeURI(tbrName)
				var sign = myFactory.hex(signStr);
				//查询保单详情信息
				$http({
					method: 'GET',
					url: app.domain + 'query/doRestPolicyDetail.action',
					params: {'chdrnum': chdrnum01,'chdrcoy': chdrcoy,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						policyData = response.data.data.policyMap.base;
						flag1 = true;//表明第一个初始化函数加载完成
					}
					/*护网行动 add by huanghaokun 20220705 start*/
					else{
						if (response.data.code == '-1') {
							myFactory.alert('', response.data.msg ,'info');
							myFactory.loadingHide();
						}else{
							myFactory.alert('','系统没有响应，请返回重试','info');
							myFactory.loadingHide();
						}
					}
					/*护网行动 add by huanghaokun 20220705 end*/
					if(flag1 && flag2){ //判断是否隐藏加载圈，如果第二个函数先完成了，那么flag2=true，这里则会执行隐藏
						initFlag = true;
						myFactory.loadingHide();
					}
				}, function errorCallback(response) {
//					if(flag1 && flag2){ //判断是否隐藏加载圈
						myFactory.loadingHide();//失败时候直接隐藏加载圈，用户才可以点返回然后重新进入
//					}
					myFactory.alert("","查询数据失败!","info");
				});
			}

			$scope.loadBgDetail = function () {
				//查询初始化变更项目数据
				myFactory.loadingShow();
				var timestamp=myFactory.getTimetamp();
				var sfis= "chdrnum-chdrcoy-token-timestamp";
				var signStr="chdrnum="+chdrnum01+"&chdrcoy="+chdrcoy+"&token="+token+"&timestamp="+timestamp;//encodeURI(tbrName)
				var sign = myFactory.hex(signStr);
				$http({
					method: 'GET',
					url: app.domain + 'input/restInitSelectItem.action',
					params: {'chdrnum': chdrnum01,'chdrcoy': chdrcoy,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						initSelectItemData = response.data.data.modelMap;
						userPassItem = response.data.data.modelMap.userPassItem;
						var items = $("p[name='item']");  //	页面p标签中所有变更项编号值
						var len = items.length;
						for( var i=0 ; i<len ; i++ ){
							var tempId = items[i].id ;	//	当前变更项编号
							if( tempId == '02_1' || tempId == '02_2' ){
								tempId = '02';
							}
							if( tempId == '12_42' ){
								tempId = '12';
							}

							//根据权限改变变更项目的字体颜色
							$("#"+items[i].id).removeClass('not_allow').addClass('weui-grid__label');//默认有该样式
							if(userPassItem.indexOf(tempId)<=-1){ //如果在权限中找不到该变更项标志
								$("#"+items[i].id).addClass('not_allow');
							}
						}
						flag2 = true;
					}
					if(flag1 && flag2){ //判断是否隐藏加载圈
						initFlag = true;
						myFactory.loadingHide();
					}
				}, function errorCallback(response) {
//					if(flag1 && flag2){ 
						myFactory.loadingHide();
//					}
					myFactory.alert("","查询数据失败!","info");
				});
			}

			//重新更新 初始化变更项目数据
			function reNewSelectItemData(){
				var timestamp=myFactory.getTimetamp();
				var sfis= "chdrnum-chdrcoy-token-timestamp";
				var signStr="chdrnum="+chdrnum01+"&chdrcoy="+chdrcoy+"&token="+token+"&timestamp="+timestamp;//encodeURI(tbrName)
				var sign = myFactory.hex(signStr);
				var deferred = $q.defer();//声明承诺
				$http({
					method: 'GET',
					url: app.domain + 'input/restInitSelectItem.action',
					params: {'chdrnum': chdrnum01,'chdrcoy': chdrcoy,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						initSelectItemData = response.data.data.modelMap;
					}
					deferred.resolve(response);//请求成功
				}, function errorCallback(response) {
					myFactory.alert("","查询数据失败!","info");
					myFactory.loadingHide();
				});
				return deferred.promise;//返回承诺
			}
			
			$scope.data = {
				/***************************菜单需求调整20170628*************************/
				change: [
					{
						project: '常用服务项目：',
						list: [
							{
								changeTypeId: '01',
								title: '通讯方式',
								src: 'images/grid/common/1.png',
								methor: "content_01_input({changeTypeId:'01',chdrnum01:"+chdrnum01+"})",
								allow: true
							},
							{
								changeTypeId: '02_1',
								title: '续期账户',
								src: 'images/grid/common/2.png',
								methor: "content_02_input({changeTypeId:'02_1',chdrnum01:"+chdrnum01+"})",
								allow: true
							},
							{
								changeTypeId: '10',
								title: '身份信息',
								src: 'images/grid/common/3.png',
								methor: "content_10_input({changeTypeId:10,chdrnum01:"+chdrnum01+"})",
								allow: false
							},
							{
								changeTypeId: '08',
								title: '身故受益人',
								src: 'images/grid/common/4.png',
								methor: "communication_data_change({changeTypeId:08,chdrnum01:"+chdrnum01+"})",
								allow: true
							},
							{
								changeTypeId: '23',
								title: '复效',
								src: 'images/grid/common/6.png',
								methor: "communication_data_change({changeTypeId:23,chdrnum01:"+chdrnum01+"})",
								allow: false
							},	
							{
								changeTypeId: '33',
								title: '结束缓缴期',
								src: 'images/grid/common/5.png',
								methor: "communication_data_change({changeTypeId:33,chdrnum01:"+chdrnum01+"})",
								allow: true
							},
							{
								changeTypeId: '19',
								title: '投资账户转换',
								src: 'images/grid/invest/4.png',
								methor: "communication_data_change({changeTypeId:19,chdrnum01:"+chdrnum01+"})",
								allow: true
							},
							{
								changeTypeId: '27',
								title: '退保',
								src: 'images/grid/common/7.png',
								methor: "communication_data_change({changeTypeId:27,chdrnum01:"+chdrnum01+"})",
								allow: true
							},
							{
								changeTypeId: '55',
								title: '犹豫期退保',
								src: 'images/grid/common/8.png',
								methor: "content_55_input({changeTypeId:55,chdrnum01:"+chdrnum01+"})",
								allow: true
							},
							{
								changeTypeId: '28',
								title: '保单借款',
								src: 'images/grid/rights/3.png',
								methor: "communication_data_change({changeTypeId:28,chdrnum01:"+chdrnum01+"})",
								allow: true
							},
							{
								changeTypeId: '38',
								title: '保单还款',
								src: 'images/grid/rights/4.png',
								methor: "communication_data_change({changeTypeId:38,chdrnum01:"+chdrnum01+"})",
								allow: true
							},
							{
								changeTypeId: '45',
								title: '领取红利',
								src: 'images/grid/rights/1.png',
								methor: "communication_data_change({changeTypeId:45,chdrnum01:"+chdrnum01+"})",
								allow: false
							},
							/*S2022011120945屏蔽移动保全、官微、官网系统中的保全变更项目“续期缴费通知选择” add by huanghaokun 20220207 start*/
							/*{
								changeTypeId: '52',
								title: '续期缴费通知',
								src: 'images/grid/others/3.png',
								methor: "communication_data_change({changeTypeId:21,chdrnum01:"+chdrnum01+"})",
								allow: false
							},*/
							{
								changeTypeId: '35',
								title: '补发保单',
								src: 'images/grid/others/7.png',
								methor: "content_35_input({changeTypeId:35,chdrnum01:"+chdrnum01+"})",
								allow: true
							},
							/*S2022011120945屏蔽移动保全、官微、官网系统中的保全变更项目“续期缴费通知选择” add by huanghaokun 20220207 end*/
							{
								changeTypeId: '54',
								title: '信函接收方式',
								src: 'images/grid/others/10.png',
								methor: "content_01_input({changeTypeId:54,chdrnum01:"+chdrnum01+"})",
								allow: false
							},
							{
								changeTypeId: '05',
								title: '红利领取方式',
								src: 'images/grid/others/5.png',
								methor: "communication_data_change({changeTypeId:05,chdrnum01:"+chdrnum01+"})",
								allow: true
							},
						]					
					}
				]
			}

//			console.log(searchParam);
			$scope.goBack = function () {
				//返回查询页面,返回查询条件
//				console.log(searchParam);
				$state.go('search',{
					searchParam:searchParam
				});
//				myFactory.goBack();
			}
			
			
//*********************无用参考部分start*********************//		
//			var s="${policy.base.statcode01}";  //保单状态（代码）
//		  	var slock="${policy.base.lcksts}"; 
//		  	var pstatcode01="${policy.base.pstatcode01}";  	//	保费状态
//		  	var path="<%=basePath %>"+"/input/initContentItem.action?itemId=";
//		  	var type="${policy.base.productType}";
//		  	var sprovid="${policy.base.sprovid}";
//**********************无用参考部分end******************//	
			
			//公用变量初始化
			var _lasFlag = "Y" ;	//	LAS检验标志
			var _itemMutual = "Y" ;		//	变更项互斥值
			var _checkBeneTerm = "Y" ;	//	检测受益人条款约定
			var _backReceipt = "Y" ;	//	回执回访结果
			var exictItems;
			
			//变更项目跳转判定
			$scope.show = function(changeTypeId){

				/*********************************************系统开放功能begin***************************************/
				/*if(app.openFlag=='openAll'){
					console.log("Permission：开发人员");
					//直接通过
				}else if(app.openFlag=='openTest'){
					console.log("Permission：测试人员");
					//01:通讯方式,,35:补发保单,36:进入缓缴期,02_2:终止续期转账,02_1:续期账户,12_42:补发客户卡,10:身份信息,19:投资账户转换
					//var isTestFunction = new Array("01","35","36","02_2","02_1","12_42","10","19");

					//03变更签名、05红利领取方式、54信函接收方式、08身故受益人
					//var isTestFunction = new Array("01","35","36","02_2","02_1","12_42","10","19","03","05","54","08","27","50","38","39","45","33","28");//第一、二阶段

					//第三阶段
					//39生存给付确认，43满期给付确认，04缴费方式，37补缴保障费用，17额外投资，47领取生存金，06保费逾期未付，52续期缴费通知，20续期投资账户选择，34终止合同结清，21部分提取，55犹豫期退保
					var isTestFunction = new Array("01","35","36","02_2","02_1","12_42","10","19","03","05","54","08","27","50","38","39","45","33","28","39","43","04","37","17","47","06","52","20","34","21","55","23");//第一、二、三阶段

					var permission='N';
					for(var i=0;i<isTestFunction.length;i++){
						var noPermission=isTestFunction[i];
						if(changeTypeId==noPermission){
							permission='Y';
							console.log("noPermission：测试人员,past:"+noPermission);
							break;
						}
					}
					if(permission=='N'){
						myFactory.alert("","功能调整中,请耐心等待!","info");
						return false;
					}
				}else{
					myFactory.alert("","功能调整中,请稍候再试!","info");
					return false;
				}*/
				/*********************************************系统开放功能end***************************************/

				//判断是否初始化完成了，如果失败，不予进入项目
				if(!initFlag){
					myFactory.alert("","初始化时失败，请返回上一步重试","info");
					return;
				}
				myFactory.loadingShow();//显示加载圈
				
				var promiseDistrict = reNewSelectItemData();
				promiseDistrict.then(function success(returnDistrict) {//成功回调
					//进行项目变更时候的一些参数读取
					var s = policyData.statcode01; //保单类型代码
					var slock = policyData.lcksts;	//SOFTLOCK标志
					var pstatcode01 = policyData.pstatcode01; //保费状态（代码）
					var type = policyData.productType;//产品类型(投连U、万能W、投连万能U,W)
					var sprovid = policyData.sprovid; ////保单地区编码
					var message = "";//用于前端返回信息
					var state = "";//跳转路由
				  	exictItems = initSelectItemData.strItemIds;	//	本次变更中所存在的全部变更项
				  	//S2020072414050 中信保诚「慧盈人生」年金保险（投资连结型） add by yangyan 20201116 start
				  	var crtable = policyData.crtable06;//险种代码
				  	//S2020072414050 中信保诚「慧盈人生」年金保险（投资连结型） add by yangyan 20201116 end
				  	
				  	//S2023072426818-PIC_保稳盈个人养老金平台营运系统需求 add by huanghk 20230906 start
				  	var gyCode = initSelectItemData.gyCode;
				  	//S2023103027791个人养老年金项目保全系统优化需求 update by huanghk 20231103 start
				  	var feeItems = "04,05,17,21,23,28,33,34,37,38,39,40,43,45,47,15,29,30";
				  	//S2023103027791个人养老年金项目保全系统优化需求 update by huanghk 20231103 end
				  	console.log("个养标识："+gyCode);
			     	if(gyCode=="Y" && feeItems.indexOf(changeTypeId)>-1){
						message = '暂不支持个人养老金保单操作';
						tipMessage(message);
					}else{
						if(changeTypeId=="01"){//保单通讯方式
				     		if((s=="IF" || s=="PU" || s=="MA" || s=="LA" || s=="NT" ) && slock=="N"){
				     			//访问模块
				     			state = "content_01_input";
				     			ExictItem(changeTypeId,type,state);
							}else {
	//							message = '保单险种或状态不符，暂不允许该变更项目，请重新确认!'
								alterMessage(message);
							}
							//Test直接放开测试
							//state = "content_01_input";
							//ExictItem(changeTypeId,type,state);
				     	}
					  	
					  	/*S2022011120945屏蔽移动保全、官微、官网系统中的保全变更项目“续期缴费通知选择” add by huanghaokun 20220207 start*/
					  	if(changeTypeId=="35"){//保单补发
				     		if((s=="IF"||s=="PU") && slock=="N"){
								state = "content_35_input";
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
					  	/*S2022011120945屏蔽移动保全、官微、官网系统中的保全变更项目“续期缴费通知选择” add by huanghaokun 20220207 end*/
					  	
				     	if(changeTypeId=="12_42"){//补发附加值服务卡  补发尊贵客户卡   补发客户卡
				     		//if((s=="IF"||s=="PU"||s=="MA"||s=="NT"||s=="LA")&& slock=="N"){
				     		if((s=="IF"||s=="PU")&& slock=="N"){
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	/*S2022011120945屏蔽移动保全、官微、官网系统中的保全变更项目“续期缴费通知选择” add by huanghaokun 20220207 start*/
				     	/*if(changeTypeId=="52"){//续期缴费通知选择
				     		if((s=="IF")&& slock=="N"){
				     			state = "content_52_input";
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}*/
				     	/*S2022011120945屏蔽移动保全、官微、官网系统中的保全变更项目“续期缴费通知选择” add by huanghaokun 20220207 end*/
				     	if(changeTypeId=="54"){//变更信函接收方式
				     		if((s=="IF"||s=="PU"||s=="LA")&& slock=="N"){
								state = "content_54_input";
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="50"){//年金领取方式变更(待检查)保单状态为IF状态的年金保单
				     		if((s=="IF")&& slock=="N"){
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="36"){//进入保险费缓缴期
				     		if((s=="IF")&& slock=="N"){
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="02_1"){//变更续期转账账户
				     		if((s=="IF")&& slock=="N"){
				     			state = "content_02_1_input";
				     			if(exictItems.indexOf("02_2")>-1){ //如果已经做了终止续期转账，则不允许做这个流程
				     				alterMessage(message);
								}else{
									ExictItem(changeTypeId,type,state);
								}
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="02_2"){//终止续期转账授权申请
				     		if((s=="IF")&& slock=="N"){
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="10"){//更改个人身份资料
				     		if((s=="IF"||s=="PU"||s=="MA")&& slock=="N"){
								state = "content_10_input";
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="08"){//变更保险金受益人     身故受益人
				     		if((s=="IF"||s=="PU")&& slock=="N"){
				     			state = "content_08_input";
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="20"){//投资账户选择
				     		if((s=="IF")&&type=="U"&& s!="LA"&&s!="MP" &&pstatcode01!="SP"&& slock=="N"){
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="19"){//投资账户转换
				     		if((s=="IF")&&type=="U"&& s!="LA"&&s!="MP" && slock=="N"){
				     			state = "content_19_input";
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="03"){//签名样式变更
				     		if((s=="IF"||s=="PU"||s=="MA")&& slock=="N"){
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}    	
				     	if(changeTypeId=="04"){//缴别变更(缴费方式变更)
				     		if((s=="IF"||pstatcode01=="PP")&&s!="PU"&&s!="MA"&&s!="NT"&&s!="LA"&&s!="MP"&& slock=="N"){
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="23"){//复效(待检查)保单状态为LA状态的非1年期意外医疗保单（产品类型为L、P、U、W、H）
				     		if((s=="LA")&& slock=="N"&&(type=="L"||type=="P"||type=="U"||type=="W"||type=="H")){
								state = "content_23_input";
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     		
				     		
				     		/*state = "content_23_input";
							myFactory.loadingHide();
							$state.go(state,{
								changeTypeId:changeTypeId,
								chdrnum01:chdrnum01,
								chdrcoy:chdrcoy,
								searchParam:searchParam
							});*/
				     	}
				     	
				     	if(changeTypeId=="33"){//结束缓缴期
				     		state="content_33_input";
				     		if((s=="IF"&&pstatcode01=="PH")&& slock=="N"&&(type=="U"||type=="W")){
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="38"){//保单还款
				     		//S2020072414050 中信保诚「慧盈人生」年金保险（投资连结型） add by yangyan 20201116 start
				     		if((s=="IF")&& slock=="N"&&(type=="L"||type=="P"||type=="W"||type=="H"||(crtable=='USBD' && type=="U"))){
				     		//S2020072414050 中信保诚「慧盈人生」年金保险（投资连结型） add by yangyan 20201116 end
				     		//if((s=="IF")&& slock=="N"){
				     			state = "content_38_input";
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="21"){//部分提取(待检查)保单状态为IF状态的投连、万能保单（产品类型为U、W）
				     		if((s=="IF")&& slock=="N"&&(type=="W"||type=="U")){
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="05"){//红利领取方式变更
				     		if( s=="IF" && slock=="N" && type=="P" ){
				     			state = "content_05_input";
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="26"){//减额缴清(待检查)保单状态为IF状态的传统及分红型保单（产品类型为L、P）
				     		if((s=="IF")&& slock=="N"&&(type=="L"||type=="P")){
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="45"){//现金红利结清
				     		
				     		if((s=="IF"||s=="PU")&& slock=="N"&&type=="P"){
				     			state = "content_45_input";
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="27"){//退保
				     		if((s=="IF"||s=="LA")&& slock=="N"){
				     			state = "content_27_input";
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="28"){//保单借款(待检查)保单状态为IF状态的传统&分红型&万能型保单
				     		//S2020072414050 中信保诚「慧盈人生」年金保险（投资连结型） add by yangyan 20201116 start
				     		if((s=="IF")&& slock=="N"&&(type=="L"||type=="P"||type=="W"||type=="H"||(crtable=='USBD' && type=="U"))){
				     			//S2020072414050 中信保诚「慧盈人生」年金保险（投资连结型） add by yangyan 20201116 end
				     			state = "content_28_input";
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="39"){//生存给付确认(待检查)保单状态为IF状态的生存金、年金保单
				     		if((s=="IF")&& slock=="N"){
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="40"){//生存给付资料变更(待检查)  保单状态为IF状态的生存金保单
				     		if((s=="IF")&& slock=="N"){
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
				     	if(changeTypeId=="47"){//领取生存保险金(待检查) 保单状态为IF状态的生存金保单
				     		if((s=="IF")&& slock=="N"){
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
				     	}
						if(changeTypeId=="55"){//犹豫期退保
							if((s=="IF"||s=="LA")&& slock=="N"){
								state = "content_55_input";
								ExictItem(changeTypeId,type,state);
							}else {
								alterMessage(message);
							}
						}
					}
					//S2023072426818-PIC_保稳盈个人养老金平台营运系统需求 add by huanghk 20230906 end
				  	
				},function error(errDistrict) {//错误回调
					myFactory.alert("","更新初始化变更项目数据失败!","info");
					myFactory.loadingHide();
				});
			}
			
			function alterMessage(message){
				message = '保单险种或状态不符，暂不允许该变更项目，请重新确认!';
				$.alert({
					 title: '',
					 text: message,
					 onOK: function () {
					 //点击确认
					 }
				});
				myFactory.loadingHide();//关闭加载圈
			}
			
			//S2023072426818-PIC_保稳盈个人养老金平台营运系统需求 add by huanghk 20230906 start
			function tipMessage(message){
				$.alert({
					 title: '',
					 text: message,
					 onOK: function () {
					 //点击确认
					 }
				});
				myFactory.loadingHide();//关闭加载圈
			}
			//S2023072426818-PIC_保稳盈个人养老金平台营运系统需求 add by huanghk 20230906 end
			
			//保单状态值校验成功后
			function ExictItem(id,type,state){
				_lasFlag = "Y" ;	//	初始化为Y
				_checkBeneTerm = "Y" ;	//	初始化为Y
				_backReceipt = "Y" ;	//	初始化为Y
				_backReceipt = "Y" ;	//	初始化为Y
				var timestamp=myFactory.getTimetamp();
				var sfis= "itemId-productType-token-timestamp";
				var signStr="itemId="+id+"&productType="+type+"&token="+token+"&timestamp="+timestamp;//encodeURI(tbrName)
				var sign = myFactory.hex(signStr);
				$http({
					method: 'GET',
					url: app.domain + '/common/restCheckForItem.action',
					params: {'itemId':id,'productType':type,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						/*console.log(response.data.data.checkLAS);
						console.log(response.data.data.checkItemMutual);
						console.log(response.data.data.checkBeneTerm);
						console.log(response.data.data.doBackReceipt);*/
						_lasFlag = response.data.data.checkLAS;
						_itemMutual = response.data.data.checkItemMutual;
						if(response.data.data.checkBeneTerm!=null && response.data.data.checkBeneTerm!=""){
							_checkBeneTerm = response.data.data.checkBeneTerm;
						}
						if(response.data.data.doBackReceipt!=null && response.data.data.doBackReceipt!=""){
							_backReceipt = response.data.data.doBackReceipt;
						}

						//经常加班到10点以上，暂时除去该控制，rqyang 20170620
						//LAS检查结果
						if( "N" ==  _lasFlag ){
							$.alert({
								 title: '',
								 text: '晚上22点至次日8点为公司日结作业时间段，日结期间系统暂停服务，不便之处，敬请谅解!',
								 onOK: function () {
								 //点击确认
								 }
							});
							myFactory.loadingHide();
							return;
						}
						
						
						//变更项互斥检查结果
						var messageTitle = "";
						//提示[ER01 - 退保、犹豫期退保只能与通讯资料变更一起做]
						if( "ER01" ==  _itemMutual ){
							messageTitle = "不能同时受理此变更项目!";	//	退保、犹豫期退保只能与通讯资料变更一起做
						}
						//	提示[ER02 - 不能同时变更收费、退费项目]
						if( "ER02" ==  _itemMutual ){
							messageTitle = "不能同时受理此变更项目!";	//	 同一次变更只能有一个涉及收、退费的项目
						}
						//	提示[ER03 - 本次变更已经存在收费或退费项目，不能进行投资账户转换变更]
						if( "ER03" ==  _itemMutual ){
							messageTitle = "不能同时受理此变更项目!";	//	本次变更已经存在收费或退费项目，不能进行投资账户转换变更
						}
						//S2018122906735移动保全新增变更项目及功能的优化需求 add by huanghaokun 20201015 start
						if( "ER04" ==  _itemMutual ){
							messageTitle = "不能同时受理此变更项目!";	//	保险类和投资类变更项目不能同时变更
						}
						if( "ER05" ==  _itemMutual ){
							messageTitle = "不能同时受理此变更项目!";	//	本次变更已经存在收费或退费项目，不能进行投资账户转换变更
						}
						//S2018122906735移动保全新增变更项目及功能的优化需求 add by huanghaokun 20201015 end
						//	异常提示
						if( "ERROR" == _itemMutual ){
							messageTitle = "互斥规则校验异常!";	//	异常处理
						}
						//如果存在以上四种情况，则弹出告示，否则不做操作
						if( "ER01" ==  _itemMutual 
							|| "ER02" ==  _itemMutual
							|| "ER03" ==  _itemMutual
							//S2018122906735移动保全新增变更项目及功能的优化需求 add by huanghaokun 20201015 start
							|| "ER04" ==  _itemMutual
					    || "ER05" ==  _itemMutual
							//S2018122906735移动保全新增变更项目及功能的优化需求 add by huanghaokun 20201015 end
							|| "ERROR" == _itemMutual){
							$.alert({
								 title: '',
								 text: messageTitle,
								 onOK: function () {
								 //点击确认
								 }
							});
							myFactory.loadingHide();
							return;
						}
						
						
						//检测受益人条款约定
						//提示[ER01 - 退保、犹豫期退保只能与通讯资料变更一起做]
						if( "N" ==  _checkBeneTerm ){
							$.alert({
								 title: '',
								 text: '保单险种或状态不符，暂不允许该变更项目，请重新确认!',
								 onOK: function () {
								 //点击确认
								 }
							});
							myFactory.loadingHide();
							return;
						}
						if( "ERROR" == _checkBeneTerm ){
							$.alert({
								 title: '',
								 text: '检测受益人条款约定出现异常!',
								 onOK: function () {
								 //点击确认
								 }
							});
							myFactory.loadingHide();
							return;
						}
						
						if( id == "27" || id == "55" ) {
							//	退保，犹豫期退保时不用检测
							//_backReceipt = "Y" ;
							console.log("退保，犹豫期退保时不用检测回执回访");
						}else{
							//检测保单回执回访结果
							//	提示[N - 回执或回访未完成]
							if( "N" ==  _backReceipt ){
								$.alert({
									title: '',
									text: '保单回执未签回/回访未完成，请先签署回执/完成回访后再申请本次变更!',
									onOK: function () {
										//点击确认
									}
								});
								myFactory.loadingHide();
								return;
							}
						}
						//	异常提示
						if( "ERROR" ==  _backReceipt ){
							$.alert({
								 title: '',
								 text: '检测保单回执回访结果异常!',
								 onOK: function () {
								 //点击确认
								 }
							});
							myFactory.loadingHide();
							return;
						}
						
						
						//判断是否曾经变更过 
						if(exictItems.indexOf(id)>-1){
							$.confirm("是否需修改变更内容", "", function() {
								myFactory.loadingHide();
								$state.go(state,{
									//userInfo:$scope.views.userInfo
									changeTypeId:id,
									chdrnum01:chdrnum01,
									chdrcoy:chdrcoy,
									searchParam:searchParam
								});
							}, function() {
								myFactory.loadingHide();
								//如果取消，则不做操作
							});
						}else{
							//alert('跳去资料修改那边');
							myFactory.loadingHide();
							$state.go(state,{
								changeTypeId:id,
								chdrnum01:chdrnum01,
								chdrcoy:chdrcoy,
								searchParam:searchParam
							});
						}		
					}
				}, function errorCallback(response) {
					myFactory.alert("","查询数据失败!","info");
					myFactory.loadingHide();
				});
			}

		}])
})(app)